<?php
error_reporting(E_ALL & ~E_NOTICE);
include './oauth2.php';
require_once "jssdk.php";
$jssdk = new JSSDK("wx9c23eb0a5329ce6d", "fe01663819b38717e1106ae02e75d655");
$signPackage = $jssdk->GetSignPackage("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
$code=$_GET['code'];//code 微信接口参数(必须)
$state=$_GET['state'];//state微信接口参数(不需传参则不用)；若传参可考虑规则： 'act'.'arg1'.'add'.'arg2'
$APPID='wx9c23eb0a5329ce6d';
$SECRET='fe01663819b38717e1106ae02e75d655';
$REDIRECT_URL='http://ethicsday.6edigital.cn/index.php';//当前页面地址
$oauth2=new oauth2();
$oauth2->init($APPID, $SECRET,$REDIRECT_URL);
if(empty($code)){       
    $oauth2->get_code_by_authorize($state);//获取code，会重定向到当前页。若需传参，使用$state变量传参。
}
$data=$oauth2->get_userinfo_by_authorize();
// echo '</br>welcome test!';
// echo '</br>nickname: '.$data['nickname'];
// echo '</br>headimgurl: '.$data['headimgurl'];
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
	<title>Ethics Day</title>
	<link rel="stylesheet" type="text/css" href="http://fwisstaticcontent.fwis2014.com/ethics/css/index.css">
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-68211850-1', 'auto');
  ga('send', 'pageview');

</script>
</head>
<body>
	<div class="layout">
		<!-- <header>
			<img src="./images/head_title_bg.png">
		</header> -->
		<section>
			<header>
				
			</header>
			<footer>
				<img class="yan" src="http://fwisstaticcontent.fwis2014.com/ethics/images/cafei_yan.png" alt="">
				<img src="http://fwisstaticcontent.fwis2014.com/ethics/images/kafei_cup_1.png" alt="">
			</footer>
		</section>
		<footer>
		<a href="./weixin.php?imgUrl=<?php echo $data['headimgurl']; ?>" onclick="clkIndex()" >
			<img src="http://fwisstaticcontent.fwis2014.com/ethics/images/btn_bg.png" alt="">
		</a>
		</footer>
	</div>
	 	<script type="text/javascript" src="http://fwisstaticcontent.fwis2014.com/ethics/js/zepto/zepto.min.js"></script>
	    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
       
        <script type="text/javascript">
        function clkIndex () {
                ga("send","event","ethicsday","click","clkIndex",1)
        }

        ga('send','pageview','/'+'index');
        
        wx.config({
            debug: false,
            appId: '<?php echo $signPackage["appId"];?>',
            timestamp: <?php echo $signPackage["timestamp"];?>,
            nonceStr: '<?php echo $signPackage["nonceStr"];?>',
            signature: '<?php echo $signPackage["signature"];?>',
            jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo']
        });
        wx.ready(function() {
            // 在这里调用 API
            wx.onMenuShareTimeline({
                title: '你有一杯咖啡等待领取', // 分享标题
                link: 'http://ethicsday.6edigital.cn/', // 分享链接
                imgUrl: 'http://fwisstaticcontent.fwis2014.com/ethics/images/cafei_paper_log.png', // 分享图标
                success: function() {
                    // 用户确认分享后执行的回调函数
                     ga("send","event","ethicsday","onMenuShareTimeline","Share-Circle-Of-Friends",2)
                   
                },
                cancel: function() {
                    // 用户取消分享后执行的回调函数
                    ga("send","event","ethicsday","onMenuShareTimeline","Share-Circle-Of-Friends",2)
                }
            });
            wx.onMenuShareAppMessage({
                title: '你有一杯咖啡等待领取', // 分享标题
                desc: '竟然有这样的好事，还不赶紧？！', // 分享描述
                link: 'http://ethicsday.6edigital.cn/', // 分享链接
                imgUrl: 'http://fwisstaticcontent.fwis2014.com/ethics/images/cafei_paper_log.png', // 分享图标
                type: 'link', // 分享类型,music、video或link，不填默认为link
                dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
                success: function() {
                    // 用户确认分享后执行的回调函数
                    ga("send","event","ethicsday","onMenuShareAppMessage","ShareWeixinMessage",3)
                },
                cancel: function() {
                    // 用户取消分享后执行的回调函数
                    ga("send","event","ethicsday","onMenuShareAppMessage","ShareWeixinMessage",3)
                }
            });
        });
        </script>
</body>
</html>